package net.togogo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class DataBd {


    //@PathVariable 绑定url中的占位符
    @RequestMapping(value = "/say/{id}",method = RequestMethod.GET)
    public String sayInfo(@PathVariable int id, Model model){
        System.out.println("id = " + id);
        model.addAttribute("username","钱多多");
        return "info";
    }

    //提交方式错误警告
/*    @RequestMapping(value = "/say/{id}",method = RequestMethod.POST)
    public String sayInfoOne(@PathVariable int id, Model model){
        System.out.println("id = " + id);
        model.addAttribute("username","钱多多");
        return "info";
    }*/

    @RequestMapping(value = "/say/{id}/{groupid}",method = RequestMethod.GET)
    public String sayInfoTwo(@PathVariable int id, @PathVariable int groupid, Model model){
        System.out.println("id = " + id + "groupid = " + groupid);
        model.addAttribute("groupid",groupid);
        model.addAttribute("username","钱多多");
        return "info";
    }


}
